import { myRequest } from '../../api/myRequest'
import { actionsMap } from '../../api/url'

const $RC = 'TextureLib'
const $RC_actions = actionsMap[$RC]

const TextureLib = {
  /**
   * 查询列表
   * @param recipient
   * @returns {Promise<*>}
   */
  queryInfoByPage(pageNumber, pageSize, filter) {
    let recipient = [
      { action: $RC_actions.QUERY_INFO_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize, ...filter },
    ]
    return myRequest($RC, recipient)
  },
  /**
   * 查询列表
   * @param recipient
   * @returns {Promise<*>}
   */
  queryInfoAll() {
    let recipient = [{ action: $RC_actions.QUERY_INFO_ALL }]
    return myRequest($RC, recipient)
  },
  /**
   * 查询列表
   * @param recipient
   * @returns {Promise<*>}
   */
  query(filter) {
    let recipient = [{ action: $RC_actions.QUERY, ...filter }]
    return myRequest($RC, recipient)
  },
  // ******************************模型配置方法开始*****************************
  /**
   * 添加信息
   * @param record
   * @returns {Promise<*>}
   */
  add(record) {
    return myRequest($RC, [{ action: $RC_actions.ADD, data: [record] }])
  },
  /**
   * 更新信息
   * @param record
   * @returns {Promise<*>}
   */
  update(record) {
    return myRequest($RC, [{ action: $RC_actions.UPDATE, data: [record] }])
  },
  /**
   * 批量删除信息
   * @param classNames
   * @returns {Promise<*>}
   */
  deleteByClassNames(classNames) {
    return myRequest($RC, [{ action: $RC_actions.DELETE_BY_CLASSNAMES, classNames }])
  },
  /**
   * 批量删除信息
   * @param ids
   * @returns {Promise<*>}
   */
  deleteByIds(ids) {
    return myRequest($RC, [{ action: $RC_actions.DELETE_BY_IDS, ids }])
  },
}

export default {
  TextureLib
}
